import ajax from '../libs/ajax.js';
import md5 from '../libs/md5.min.js';

let txtPwd = document.getElementById('txtPwd');
let btnLogin = document.getElementById('btnLogin');

btnLogin.addEventListener('click', () => {
  let user = {
    username: 'app-admin',
    password: md5.hash(txtPwd.value)
  };
  ajax.send('/user/auth/login', user, (data) => {
    if (!data.success) {
      showToast('请输入正确的密令');
      return;
    } else{
      location.href = '../ymguanli/guanliyuan.html';
    }
        
    
    
  });
});

//#region 公用的轻提示对话框

let liveToast = document.getElementById('liveToast');
let liveToastMessing = document.querySelector('#liveToast .toast-body');

const toast = new bootstrap.Toast(liveToast);

function showToast(message) {
  liveToastMessing.innerHTML = message;
  toast.show();
}
//#endregion
